<?php
ob_start();
	include 'connect/connect.php';
	include 'class/class.phieuthu.php';

?>

<form method="POST" action="#">
	<p>
		<select size="1" name="timkiem">
			<option value="1" <? if ($_POST['timkiem'] == 1){ echo ' selected';}?>>Sinh Vien</option>
			<option value="2" <? if ($_POST['timkiem'] == 2){ echo ' selected';}?>>Ke toan vien</option>
			<option value="3" <? if ($_POST['timkiem'] == 3){ echo ' selected';}?>>Chu doanh nghiep</option>
			<option value="4" <? if ($_POST['timkiem'] == 4){ echo ' selected';}?>>Dac biet</option>
		</select>
		<input type="submit" value="Tìm ki&#7871;m" name="B1"></p>
</form>
<?php   
		$phieuthu = new phieuthu;
		$timkiem =0;
		if(isset($_POST['timkiem']))
			$timkiem =$_POST['timkiem'];
		if ($timkiem == 1) {
			$result = mysql_query("SELECT * FROM tbl_thuphieu WHERE f_nghenghiep = 1 order by f_maphieu")
			or die(mysql_error()); 
			echo "
	<table border='1' width='900'>
";
			echo   '
<td width="30" bgcolor="#D6E0D8">ID</td>
<td width="100" bgcolor="#D6E0D8">Họ và tên</td>
<td width="100" bgcolor="#D6E0D8">Nghề nghiệp</td>
<td width="100" bgcolor="#D6E0D8">Trạng thái</td>
<td width="100" bgcolor="#D6E0D8">Edit</td>
';
			while ($row = mysql_fetch_array($result))
			{
				$ketqua = mysql_query("SELECT * 
								FROM  `comment` 
								WHERE  `mhs` =".$row['f_maphieu']."
								LIMIT 0 , 30"); 
					echo "
<tr>
	";
					echo "
	<td>" . $row['f_maphieu'] . "</td>
	";
					echo "
	<td>" . $row['f_hovaten'] . "</td>
	";			  
					echo "
	<td>" . $phieuthu->nghe_nghiep($row['f_nghenghiep'])  . "</td>
	";
		echo "
	<td>
		";
		while ($cot = mysql_fetch_array($ketqua)) {
			echo "<b>".$cot['author'].'('.$cot['date'].')</b>:'.$cot['comment']."<br />";
		}
		echo "
	</td>
	";
					echo '
	<td bgcolor="#D6E0D8">
		<a href="edit.php?stt='.$row['f_maphieu'] .'">Edit</a>
	</td>
	'	;
					echo "
</tr>
";		
			} 
		}
		else if ($timkiem == 2) {
			$result = mysql_query("SELECT * FROM tbl_thuphieu WHERE f_nghenghiep = 2 order by f_maphieu")
			or die(mysql_error()); 
			echo "
<table border='1' width='900'>
	";
			echo   '
	<td width="30" bgcolor="#D6E0D8">ID</td>
	<td width="100" bgcolor="#D6E0D8">Họ và tên</td>
	<td width="100" bgcolor="#D6E0D8">Nghề nghiệp</td>
	<td width="100" bgcolor="#D6E0D8">Trạng thái</td>
	<td width="100" bgcolor="#D6E0D8">Edit</td>
	';
			while ($row = mysql_fetch_array($result))
			{
				$ketqua = mysql_query("SELECT * 
								FROM  `comment` 
								WHERE  `mhs` =".$row['f_maphieu']."
								LIMIT 0 , 30"); 
					echo "
	<tr>
		";
					echo "
		<td>" . $row['f_maphieu'] . "</td>
		";
					echo "
		<td>" . $row['f_hovaten'] . "</td>
		";			  
					echo "
		<td>" . $phieuthu->nghe_nghiep($row['f_nghenghiep'])  . "</td>
		";
		echo "
		<td>
			";
		while ($cot = mysql_fetch_array($ketqua)) {
			echo "<b>".$cot['author'].'('.$cot['date'].')</b>:'.$cot['comment']."<br />";
		}
		echo "
		</td>
		";
					echo '
		<td bgcolor="#D6E0D8">
			<a href="edit.php?stt='.$row['f_maphieu'] .'">Edit</a>
		</td>
		'	;
					echo "
	</tr>
	";
				
			} 
		}
		else if ($timkiem == 3) {
			$result = mysql_query("SELECT * FROM tbl_thuphieu WHERE f_nghenghiep = 3 order by f_maphieu")
			or die(mysql_error()); 
			echo "
	<table border='1' width='900'>
		";
			echo   '
		<td width="30" bgcolor="#D6E0D8">ID</td>
		<td width="100" bgcolor="#D6E0D8">Họ và tên</td>
		<td width="100" bgcolor="#D6E0D8">Nghề nghiệp</td>
		<td width="100" bgcolor="#D6E0D8">Trạng thái</td>
		<td width="100" bgcolor="#D6E0D8">Edit</td>
		';
			while ($row = mysql_fetch_array($result))
			{
				$ketqua = mysql_query("SELECT * 
								FROM  `comment` 
								WHERE  `mhs` =".$row['f_maphieu']."
								LIMIT 0 , 30"); 
					echo "
		<tr>
			";
					echo "
			<td>" . $row['f_maphieu'] . "</td>
			";
					echo "
			<td>" . $row['f_hovaten'] . "</td>
			";			  
					echo "
			<td>" . $phieuthu->nghe_nghiep($row['f_nghenghiep'])  . "</td>
			";
		echo "
			<td>
				";
		while ($cot = mysql_fetch_array($ketqua)) {
			 echo "<b>".$cot['author'].'('.$cot['date'].')</b>:'.$cot['comment']."<br />";
		}
		echo "
			</td>
			";
					echo '
			<td bgcolor="#D6E0D8">
				<a href="edit.php?stt='.$row['f_maphieu'] .'">Edit</a>
			</td>
			'	;
					echo "
		</tr>
		";
				
			} 
		}
		else if ($timkiem == 4) {
			$result = mysql_query("SELECT * FROM tbl_thuphieu WHERE f_nghenghiep=4 order by f_maphieu")
			or die(mysql_error()); 
			echo "
		<table border='1' width='900'>
			";
			echo   '
			<td width="30" bgcolor="#D6E0D8">ID</td>
			<td width="100" bgcolor="#D6E0D8">Họ và tên</td>
			<td width="100" bgcolor="#D6E0D8">Nghề nghiệp</td>
			<td width="100" bgcolor="#D6E0D8">Khóa</td>
			<td width="100" bgcolor="#D6E0D8">Edit</td>
			';
			while ($row = mysql_fetch_array($result))
			{
				$ketqua = mysql_query("SELECT * 
								FROM  `comment` 
								WHERE  `mhs` =".$row['f_maphieu']."
								LIMIT 0 , 30"); 
					echo "
			<tr>
				";
					echo "
				<td>" . $row['f_maphieu'] . "</td>
				";
					echo "
				<td>" . $row['f_hovaten'] . "</td>
				";			  
					echo "
				<td>" . $phieuthu->nghe_nghiep($row['f_nghenghiep'])  . "</td>
				";
		echo "
				<td>
					";
		while ($cot = mysql_fetch_array($ketqua)) {
			 echo "<b>".$cot['author'].'('.$cot['date'].')</b>:'.$cot['comment']."<br />";
		}
		echo "
				</td>
				";
					echo '
				<td bgcolor="#D6E0D8">
					<a href="edit.php?stt='.$row['f_maphieu'] .'">Edit</a>
				</td>
				'	;
					echo "
			</tr>
			";
				
			} 
		}
echo "
		</table>
		";
?>